package com.czkt.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.czkt.pojo.Books;
import com.czkt.pojo.Vo.BooksVo;
import com.czkt.service.BooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
@CrossOrigin
public class BooksController {
    @Autowired
    BooksService booksService;
    @PreAuthorize("hasRole('普通用户')")
    @RequestMapping("/books/getBooksList")
    public Object getBooksLIst(@RequestParam(defaultValue = "1") Integer pageIndex, @RequestParam(defaultValue = "3") Integer pageSize) {
        Page<BooksVo> page = new Page<>(pageIndex,pageSize);
        IPage<BooksVo> booksVoIPage = booksService.boooksLIst(page);
        return booksVoIPage;
    }
}
